﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

#endregion

namespace ScrumTable.UI.View.Converter
{

    /// <summary>
    /// converts a empty string to boolan
    /// </summary>
    [ValueConversion(typeof(Orientation), typeof(ScrollBarVisibility))]
    public class ConverterOrientationToScrollBarVisibility : IValueConverter
    {

        public bool IsVertical { get; set; }

       

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------
        /// <summary>
        /// String.IsNullOrEmpty(value.ToString()); ;
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// String.IsNullOrEmpty(value.ToString()); ;
        /// </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Orientation orientation = (Orientation)value;
            if (orientation == Orientation.Horizontal && IsVertical)
            {
                 return ScrollBarVisibility.Hidden;
            }
            if( orientation == Orientation.Horizontal && !IsVertical )
            {
                return ScrollBarVisibility.Visible;
            }
            if( orientation == Orientation.Vertical && IsVertical )
            {
                return ScrollBarVisibility.Visible;
            }
            if( orientation == Orientation.Vertical && !IsVertical )
            {
                return ScrollBarVisibility.Hidden;
            }
            return null;
        }

        /// <summary>
        /// Not supported. Throws NotSupportedException.
        /// </summary>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();

        }
       
        #endregion


       
    }
}
